{template 'common/header'}
<style type="text/css">
    #juzhong{text-align:center;}
</style>
<form class="table-top-search form-inline" id="search_table" method="post" action="{php echo aurl(4)}">
    <div class="btn-group" role="group" aria-label="...">
        <a class="btn btn-default" href="{php echo wurl('site/entry', array('et' =>2, 'eid' => $_GET['eid'], 'version_id'=>0))}" role="button">新增</a>
        <a class="btn btn-default" href="javascript:;" role="button" id="del">删除</a>
        <a href="javascript:;" type="checkbox" class="btn btn-default" onclick="checkall(this, '.check-all')" data-checked="0">全选</a>

    </div>
</form>

<form name="acform" method="post" id="acform" action="{php echo aurl(4)}">
    <input type="hidden" name="url" value>
    <table class="table table-striped"> 
        <thead>
            <tr>
                <td>#</td>
                <td>编号</td>
                <td>标题</td>
                <td>所属分类</td>
                <td>价格</td>
                <td>关联客服</td>
                <td>到期时间</td>
                <td>状态</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
        {loop $sumdate $item}
            <tr>
                <td>
                    <input type="checkbox" name="checkbox[]" class="check-all" value="{php echo $item['id']}">
                </td>
                <td>{$item['id']}</td>
                <td>{$item['title']}</td>
                <td>{$item['sort']}</td>
                <td>{$item['price']}</td>
                <td>{$item['incooker']}</td>
                <td>{$item['time']}</td>
                <td>{php echo action_state($item['state'])}</td>
                <td>
                    <a type="submit" role="button" href="{php echo wurl('site/entry',array('eid'=>4,'version_id'=>0,'et'=>5,'uid'=>$item['id']))}">修改</a>
                    <a type="submit" role="button" href="{php echo wurl('site/entry',array('eid'=>4,'version_id'=>0,'et'=>7,'uid'=>$item['id']))}">订单</a>
                    <a href="javascript:;" data-toggle="modal" data-target="#myModal{$item['id']}">预览</a>

                    <div class="modal fade" id="myModal{$item['id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel">二维码</h4>
                                </div>
                                <div class="modal-body" id="juzhong">
                                    <img src="{php echo $this->createWebUrl('serviceuser', ['et'=>10, 'rand'=>random(10)])}">
                                </div>
                                    <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <a href="javascript:;" class="clipboard" data-clipboard-text="{php echo $_W['siteroot'].'app/'.$this->createMobileUrl('home', ['id'=>$item['id']])}">复制活动链接</a>
                </td>
            </tr>
        {/loop}
        </tbody>
    </table>  
</form>
{$sortpage}

<script>
    function checkall(_this, dom) {
        var isCheck = $(_this).attr('data-checked');
        if(isCheck == '0') {
            $(dom).prop('checked', true);
            $(_this).attr('data-checked', '1');
        } else {
            $(dom).prop('checked', false);
            $(_this).attr('data-checked', '0');
        }
    }
    $('#del').on('click',function() {
        $('#acform').submit();
    })

    require.config({
　　　　paths: {
　　　　　　"clipboard": "../lib/clipboard.min"
　　　　}
　　});
    require(['clipboard'], function(clip) {
        var c = new clip('.clipboard');
        c.on('success', function(e) {
            // console.log(e);
            alert('复制成功');
            e.clearSelection();
        });
    });
</script>
{template 'common/footer'}